package com.abc.controller;


import com.abc.entity.Programme;
import com.abc.service.IProgrammeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2024-12-25
 */


@RestController
@RequestMapping("/programme")
@Api(tags = "节目管理")
public class ProgrammeController {
    @Autowired
    private IProgrammeService programmeService;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据ID获取节目", notes = "传入节目的ID")
    public Programme getProgrammeById(@PathVariable Integer id) {
        return programmeService.getById(id);
    }

    @PostMapping
    @ApiOperation(value = "添加节目", notes = "传入节目的详细信息")
    public boolean addProgramme(@RequestBody Programme programme) {
        return programmeService.save(programme);
    }

    @PutMapping
    @ApiOperation(value = "更新节目", notes = "传入节目的详细信息")
    public boolean updateProgramme(@RequestBody Programme programme) {
        return programmeService.updateById(programme);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除节目", notes = "传入节目的ID")
    public boolean deleteProgramme(@PathVariable Integer id) {
        return programmeService.removeById(id);
    }
}
